﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class t_modify_pesonal_info : System.Web.UI.Page
{
    string userid;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] == null || Session["UserIdentity"].ToString() != "1")
        {
            Response.Redirect("Default.aspx", false);
            HttpContext.Current.ApplicationInstance.CompleteRequest();
            return;
        }
        else userid = Session["UserId"].ToString();
        return;
    }
    protected void ModifyBtn_Click(object sender, EventArgs e)
    {
        try
        {
            string strPwd = PwdTextBox1.Text;
            string sqlString = "update UserInfo set password=" + strPwd + " where UserId=" + userid;
            SqlConnection conn = new SqlConnection("Data Source=Localhost;Integrated Security=SSPI;Initial Catalog=CSHDB");
            conn.Open();
            SqlCommand command = new SqlCommand(sqlString, conn);
            command.ExecuteNonQuery();
            conn.Close();
            ErrorLabel.Text = "修改密码成功！";
            ErrorLabel.Visible = true;
            PwdTextBox1.Text = "";
            PwdTextBox2.Text = "";
            return;
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = "修改密码失败:" + ex.Message;
            ErrorLabel.Visible = true;
            return;
        }


    }
}
